

///////////////////////////////////////////////////////////
////   Prepare MACRO Data Before Merge with MAIN DATA   /////////
//////////////////////////////////////////////////////////

**********
* VIX 
**********
import excel  "${rawdata}/macro/vix.xls", clear first
generate year = year(observation_date)
rename VIXCLS vix
collapse (mean) vix, by(year)
label variable vix "(mean) Volatility index (CBOE)"
tempfile vix
save `vix' 

**********
* DK - GDP growth
**********
import excel  "${rawdata}/macro/DK_real_gdp_growth_rate.xls", clear first
generate year = year(observation_date)
drop observation_date
label variable DK_real_gdp_grate "Real GDP growth rate - Denmark"
tempfile DK_real_gdp_growth_rate
save `DK_real_gdp_growth_rate' 

**********
* DK - GDP growth 1Y forecast
**********
import excel  "${rawdata}/macro/IMF_forecast_DK_GDP.xls", clear first
label variable gdp_growth_forecast "Real GDP growth rate 1Y forecast- Denmark"
rename gdp_growth_forecast DK_gdp_growth_forecast
tempfile IMF_forecast_DK_GDP
save `IMF_forecast_DK_GDP' 

**********
* DK - CPI inflation
**********
import excel  "${rawdata}/macro/DK_infl_rate.xls", clear first
generate year = year(observation_date)
drop observation_date
label variable DK_inflation_rate "CPI inflation rate - Denmark"
tempfile DK_infl_rate
save `DK_infl_rate' 

**********
* Jarocinski - Karadi : Euro area monetary policy shocks
**********
insheet using "${rawdata}/macro/data_fig9.csv", clear
collapse (sum) eureon3m_hf  mpshocksign, by(year)
rename eureon3m_hf JK_eureon3m_hf
rename mpshocksign JK_mpshocksign
label variable JK_eureon3m_hf "(sum) Jarocinski - Karadi - EUR Eonia 3M high frequency shock"
label variable JK_mpshocksign "(sum) Jarocinski - Karadi - Monetary policy shock, sign restrictions"
tempfile JK_shocks
save `JK_shocks' 

**********
* Altavilla et al. - Euro area monetary policy shocks
**********
clear
import excel "${rawdata}/macro/Dataset_EA-MPD.xlsx", sheet("Monetary Event Window") firstrow
gen year = year(date)
format year %ty
collapse (sum) OIS_3M OIS_1Y OIS_10Y DE10Y, by(year)

replace OIS_10Y = . if OIS_10Y == 0.0 // collapse sum produces a 0.0 value if all quartlery obs. were missing, this line corrects it 

gen AL_OIS3M_mpshock = OIS_3M / 100
gen AL_OIS1Y_mpshock = OIS_1Y / 100
gen AL_OIS10Y_mpshock = OIS_10Y / 100
gen AL_DE10Y_mpshock = DE10Y / 100

label var AL_OIS3M_mpshock "(sum) MP shock (High Freq. 3M OIS; Altavilla 2018)"
label var AL_OIS1Y_mpshock "(sum) MP shock (High Freq. 1Y OIS; Altavilla 2018)"
label var AL_OIS10Y_mpshock "(sum) MP shock (High Freq. 10Y OIS; Altavilla 2018)"
label var AL_DE10Y_mpshock "(sum) MP shock (High Freq. 10Y DE; Altavilla 2018)"

tempfile Altavilla_shocks
save `Altavilla_shocks' 

////////////////////////////////////////////////////////
////  Join All Macro Variables into One File   /////////
////////////////////////////////////////////////////////
use `vix'
joinby year using `DK_real_gdp_growth_rate', unmatched(both)
drop _merge 
joinby year using `IMF_forecast_DK_GDP', unmatched(both)
drop _merge 
joinby year using `DK_infl_rate', unmatched(both)
drop _merge
joinby year using `JK_shocks', unmatched(both)
drop _merge
joinby year using `Altavilla_shocks', unmatched(both)
drop _merge

keep if inrange(year,2003,2018)
compress
save "${procdata}/macro_data.dta", replace 


